Skip to content

feat: add session profiles (custom CLI environment per session)#39

Merged
dakl merged 5 commits intomainfrom
custom-commands
Apr 4, 2026
Merged

feat: add session profiles (custom CLI environment per session)#39
dakl merged 5 commits intomainfrom
custom-commands

Conversation

@dakl
Copy link
Copy Markdown
Owner

@dakl dakl commented Apr 4, 2026

Summary

  • Adds a Profiles system that lets users define named CLI configurations (executable, extra args, env vars) and select one when creating a session
  • Profiles are stored per-session in the DB so each terminal inherits the correct environment and binary
  • Sources the user's login shell env (~/.zshrc, ~/.zprofile) into every PTY session, fixing missing PATH/API keys in Electron-launched processes

What changed

Data model

  • New CommandProfile type with name, executable, extraArgs, envVars fields
  • SessionInfo extended with binaryName, extraArgs, profileName, envVars
  • DB migrations v5–v7 add binary_name, extra_args, preset_name, env_vars columns to sessions

Shell environment

  • shell-env.ts: runs $SHELL -l -c 'source ~/.zshrc; printenv' once at startup and caches the result; injected into every PTY spawn so tools on PATH and env vars set in dotfiles are available
  • Profile-level envVars (newline-separated KEY=VALUE) are overlaid on top, allowing per-session overrides like CLAUDE_CONFIG_DIR

PTY / agent layer

  • PtyManager.create accepts binaryNameOverride, extraArgsStr, and envVarsStr; shellEnvProvider is injectable for tests
  • ClaudeAdapter appends extraArgs to both buildStartArgs and buildResumeArgs
  • session-lifecycle uses session.binaryName ?? agentType for the spawn binary

IPC

  • sessions:create resolves profileIdCommandProfile and stores all profile fields in the DB
  • pty:create reads the stored profile fields and passes them to PtyManager
  • pty:input errors on dead PTY sessions are now silenced (.catch(() => {}))

UI

  • Settings → Profiles: add, edit (inline), and delete profiles; env vars entered as a textarea (one per line)
  • New session dialog: profile dropdown loads independently of branch fetch (a git error can no longer hide it)
  • Sidebar: profile name shown in accent color on the sub-line next to branch name; branch truncates to make room

Testing

  • 253 unit/integration tests passing
  • New tests cover: DB migrations v5–v7, createSession with profileName/envVars, PtyManager env merging and envVarsStr injection, ClaudeAdapter extraArgs in start and resume
  • shell-env.ts parseEnvOutput has 7 unit tests covering edge cases (noise lines, multiline values, empty input)

dakl added 5 commits April 4, 2026 16:39
- Add CommandProfile type (executable, extraArgs, envVars, profileName)
- Extend SessionInfo with binaryName, extraArgs, profileName, envVars
- DB migrations v5-v7: binary_name, extra_args, preset_name, env_vars columns
- MIGRATIONS map changed from single strings to string[] for multi-statement safety
- shell-env.ts: load user login+interactive env once via zsh -l -c,
  so PATH, API keys, and .zshrc vars are available to agent processes
- PtyManager: accept shellEnvProvider (injectable for tests) and
  envVarsStr (newline-separated KEY=VALUE pairs from profile)
- ClaudeAdapter / agent-registry: thread extraArgs through to
  buildStartArgs and buildResumeArgs
- session-lifecycle: use session.binaryName for spawn, parse extraArgs
- sessions:create resolves profileId -> CommandProfile, stores
  binaryName/extraArgs/profileName/envVars in DB
- pty:create reads profile fields from session record and passes
  to PtyManager
- sessionStore and Sidebar forward profileId through onConfirm chain
- SettingsPanel: Profiles section with add/edit/delete, fields for
  executable, extra args, and env vars (newline-separated KEY=VALUE)
- NewSessionDialog: profile dropdown (loads independently of branch
  fetch so a git error can't hide it), forwards profileId on confirm
- SessionListItem: show profile name in accent color on sub-line,
  branch truncates to make room
- TerminalView: silence pty:input errors on dead PTY sessions
- DB migrations v5/v6/v7 — columns exist and default to null
- createSession stores/returns profileName and envVars correctly
- PtyManager: shell env merging, CLAUDECODE stripping, binaryName
  override, extraArgs/envVars injection
- ClaudeAdapter: extraArgs appended in both start and resume args
Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@dakl dakl merged commit 72ccaae into main Apr 4, 2026
3 checks passed
@dakl dakl deleted the custom-commands branch April 4, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant